package UnitTest.DataStructureTest.arrayAndListTest.listTest.listReverseTest;

import DataStructure.arrayAndList.list.ListReverse;
import DataStructure.arrayAndList.list.Nodelj;
import DataStructure.arrayAndList.list.listReverse.ListReverseByMultiPoint;
import DataStructure.arrayAndList.list.listReverse.ListReverseBySystemStack;
import org.junit.Test;

/**
 * @author liujun
 * @version 1.0
 * @date 2021/12/7
 * @author—Email ljfirst@mail.ustc.edu.cn
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 反转链表
 */
public class ListReverseTest extends ListReverseDate {

    Nodelj node = new Nodelj();

    @Test
    public void testListReverseByMultiPoint() {
        // 利用指针关系
        testListReverse(new ListReverseByMultiPoint());
    }

    @Test
    public void testListReverseBySystemStack() {
        // 利用系统栈
        testListReverse(new ListReverseBySystemStack());
    }

    public void testListReverse(ListReverse listReverse) {
        Nodelj answer = listReverse.reverse(list01);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_01));
        answer = listReverse.reverse(list02);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_02));
        answer = listReverse.reverse(list03);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_03));
        answer = listReverse.reverse(list04);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_04));
        answer = listReverse.reverse(list05);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_05));
        answer = listReverse.reverse(list06);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_06));
        answer = listReverse.reverse(list07);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_07));
        answer = listReverse.reverse(list08);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_08));
        answer = listReverse.reverse(list09);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_09));
        answer = listReverse.reverse(list10);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_10));
        answer = listReverse.reverse(list11);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_11));
        answer = listReverse.reverse(list12);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_12));
        answer = listReverse.reverse(list13);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_13));
        answer = listReverse.reverse(list14);
        assert node.equals(answer, node.Array2Nodelj(array_Reverse_14));
    }
}
